import Phaser from 'phaser';

import UtilsCoordinateConter from '../../../utils/Utils.coordinate.conter/UtilsCoordinateConter';
import SaveSceneExampleQueue from '../../../utils/Utils.SaveSceneExampleQueue/UtilsSaveSceneExampleQueue';
import UtilsLoader from '../../../utils/Utils.loader/UtilsLoader';

export default class SceneUiTask extends Phaser.Scene {
    constructor() {
        super({
            key: 'SceneUiTask'
        });

        this.textFrame = null;
        this.textFrameVis = false;

        this.WWC = UtilsCoordinateConter.coordinatrConter('world').WWC;
        this.WHC = UtilsCoordinateConter.coordinatrConter('world').WHC;
        this.WFW = UtilsCoordinateConter.coordinatrConter('worldFull').WFW;
        this.WFH = UtilsCoordinateConter.coordinatrConter('worldFull').WFH;
        this.VWC = UtilsCoordinateConter.coordinatrConter('view').VWC;
        this.VHC = UtilsCoordinateConter.coordinatrConter('view').VHC;
        this.VFW = UtilsCoordinateConter.coordinatrConter('viewFull').VFW;
        this.VFH = UtilsCoordinateConter.coordinatrConter('viewFull').VFH;
    }

    init() {
        console.log('SceneUiTask init!');

        SaveSceneExampleQueue.enQueue({
            'SceneUiTask': this
        });
    }

    preload() {
        console.log('SceneUiTask pre!');

        this.IMAGE_LOAD();
    }

    create() {
        console.log('SceneUiTask create!');

        this.textFrame = this.add.image(this.VWC, this.VHC, 'textFrame')
        .setInteractive()
        .setVisible(this.textFrameVis);

        this.onClick();
    }

    IMAGE_LOAD() {
        new UtilsLoader('image', [{
            key: 'textFrame',
            path: '/images/phaser/textFrame.png'
        }], 'http://localhost:3001', this, (e) => {
            console.log(e);
        });
    }

    onClick() {
        // on textFrame...
        this.textFrame.on('pointerdown', () => {
            this.events.emit('onCloseTextFrame', '关闭任务!');
        });
    }

}